package com.cuckoo.mall.thus.order.orderlist.paidorder;

import android.support.annotation.Nullable;
import android.text.Html;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bgn.baseframe.utils.BaseStringUtil;
import com.bgn.baseframe.utils.imageloader.ImageLoader;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cuckoo.mall.R;
import com.cuckoo.mall.javabean.Goods;
import com.cuckoo.mall.javabean.Product;

import java.util.List;

/**
 * Created by Administrator on 2018/3/31.
 */

public class OrderListImageQiuckAdapter extends BaseQuickAdapter<Product, BaseViewHolder> {
    private int size = 0;

    public OrderListImageQiuckAdapter(@Nullable List<Product> data) {
        super(R.layout.list_item_order_image, data);
        size = data.size();
    }

    @Override
    protected void convert(final BaseViewHolder helper, final Product item) {
       // helper.setText(R.id.tv_property, "暂时放");
        helper.setText(R.id.tv_property, BaseStringUtil.getAtributeSting(item.getAttribute()));
        helper.setText(R.id.tv_counts, "x" + item.getNumber());


        helper.setText(R.id.tv_name, item.getName());
        helper.setText(R.id.tv_price, item.getCurrency()+" " + BaseStringUtil.getPrioceFormatString(item.getPrice()));

        if (item.getMarket_price() != 0) {
            helper.setText(R.id.tv_max_price, BaseStringUtil.addDeleteLineToText(item.getCurrency() + " " + BaseStringUtil.getPrioceFormatString(item.getMarket_price())));
            //helper.setText(R.id.tv_max_price, Html.fromHtml("<strike>" + item.getCurrency()+" " + BaseStringUtil.getPrioceFormatString(item.getMarket_price()) + "</strike>"));
        } else {
            helper.setText(R.id.tv_max_price, "");
        }

        ImageLoader.load(item.getImage()).into((ImageView) helper.getView(R.id.iv_image));
        if (helper.getAdapterPosition() == size - 1) {
            helper.setGone(R.id.view_line, false);
        } else {
            helper.setGone(R.id.view_line, true);
        }
    }

}
